﻿@model FunPlus.Application.Marketing.Dto.GetSubsidyItemOutput


@{
    Layout = null;
}

<html style="height: auto; min-height: 100%;">
<head>
    <title>趣+后台管理系统</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <link rel="stylesheet" href="/Content/AdminLTE/plugins/bootstrap/dist/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link href="/Content/AdminLTE/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- Ionicons -->
    <link rel="stylesheet" href="/Content/AdminLTE/plugins/Ionicons/css/ionicons.min.css">
    <link rel="stylesheet" href="/Content/AdminLTE/plugins/bootstrap-daterangepicker/daterangepicker.css">
    <link rel="stylesheet" href="/Content/AdminLTE/plugins/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
    <link rel="stylesheet" href="/Content/AdminLTE/plugins/datatables.net-bs/css/dataTables.bootstrap.min.css">
    <!-- Theme style -->
    <link href="/Content/AdminLTE/dist/css/AdminLTE.css" rel="stylesheet">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link href="/Content/AdminLTE/dist/css/skins/skin-blue.min.css" rel="stylesheet">
    <link href="/Content/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="/Content/css/layerui/layui.css" rel="stylesheet">
    <link rel="stylesheet" href="http://localhost:49304/Content/plugins/layer/skin/layer.css" id="layui_layer_skinlayercss" style="">
</head>
<body class="skin-blue sidebar-mini" style="height: auto; min-height: 100%;">
    <div class="wrapper" style="height: auto; min-height: 100%;">
        <div class="content-wrapper" style="min-height: 629.2px; margin:0px;">
            <!-- Main content -->
            <section class="content">
                <div class="box">
                    <div class="box-body">
                        <div class="col-md-12">
                            <form class="form-horizontal" method="post" id="form-add">
                                @Html.AntiForgeryToken()
                                @Html.HiddenFor(model => model.subsidy_id)
                                @Html.HiddenFor(model => model.id)

                                <div class="form-horizontal">
                                    <div class="form-group">
                                        @Html.LabelFor(model => model.name, htmlAttributes: new { @class = "control-label col-md-2" })
                                        <div class="col-md-10">
                                            <input type="text" class="form-control" id="name" name="name" placeholder="标题" />
                                            @*@Html.EditorFor(model => model.name, new { htmlAttributes = new { @class = "form-control" } })*@
                                            @Html.ValidationMessageFor(model => model.name, "", new { @class = "text-danger" })
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        @Html.LabelFor(model => model.rate, htmlAttributes: new { @class = "control-label col-md-2" })
                                        <div class="col-md-10">
                                            <input type="text" class="form-control" id="rate" name="rate" placeholder="返现比例 20=20% 返现金额=实际支付金额20%" />
                                            @Html.ValidationMessageFor(model => model.rate, "", new { @class = "text-danger" })
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        @Html.LabelFor(model => model.total_cycle, htmlAttributes: new { @class = "control-label col-md-2" })
                                        <div class="col-md-10">
                                            <input type="text" class="form-control" id="total_cycle" name="total_cycle" placeholder="返现周期 如:6=6个月" />
                                            @Html.ValidationMessageFor(model => model.total_cycle, "", new { @class = "text-danger" })
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        @Html.LabelFor(model => model.remark, htmlAttributes: new { @class = "control-label col-md-2" })
                                        <div class="col-md-10">
                                            <input type="text" class="form-control" id="remark" name="remark" placeholder="备注" />
                                            @Html.ValidationMessageFor(model => model.remark, "", new { @class = "text-danger" })
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <div class="col-sm-4 col-sm-offset-3">
                                            <button class="btn btn-primary" type="submit">保存</button>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </section>
            <!-- /.content -->
        </div>
    </div>

    <script src="/Content/js/jquery.min.js"></script>
    <script src="/Content/js/common.js"></script>
    <script src="/Content/plugins/layer/layui.js"></script>
    <script src="/Content/plugins/layer/layer.min.js"></script>
    <script src="/Content/js/jquery.form.js"></script>
    <script src="/Content/plugins/validate/jquery.validate.min.js"></script>
    <script src="/Content/plugins/validate/messages_zh.min.js"></script>
    <script type="text/javascript">
        var subsidy_id = getURLParameter("subsidy_id");        
        $(function () {
            if (subsidy_id.length == 0 || subsidy_id == 0) {
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            }
        })

        $("#form-add").validate({
            ajaxPost: true,
            submitHandler: function (form) {
                infosubmit();
            }
        });

        var flag = true;
        function infosubmit() {
            var name = $('#name');
            var rate = $('#rate');
            var total_cycle = $('#total_cycle');
            if (name.length == 0) {
                alert("标题不能为空");
                return;
            }
            if (rate > 100) {
                alert("比例不能超过100");
                return;
            }

            if (flag) {
                $("#form-add").ajaxSubmit({
                    type: "post",
                    url: "/Marketing/SubsidyItem",
                    dataType: "json",
                    success: function (result) {                        
                        if (result.code == 1) {
                            parent.layer.msg("操作成功", { time: 1200 }, function () {
                                window.parent.location.reload();
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                            });
                        }
                        else {
                            alert(result.msg);
                        }
                    }
                });
            }
        }

    </script>
</body>
</html>
